package com.zeyi.chat.views;

import com.zeyi.chat.utils.FXMLUtil;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * @author zeyi
 */
public class Alert {

    public Alert(String text, Stage MainStage) {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                Stage stage = new Stage();
                Scene scene = FXMLUtil.createScene("/Fxml/Alert.fxml");
                new CircleBorder(scene, 10, "#E4E7ED");
                Label label = (Label) scene.lookup("#info");
                label.setText(text);
                stage.setScene(scene);
                stage.initOwner(MainStage);
                stage.initModality(Modality.APPLICATION_MODAL);
                stage.initStyle(StageStyle.TRANSPARENT);
                double x = MainStage.getX();
                double y = MainStage.getY();
                stage.setX(x + MainStage.getWidth() / 2 - 250);
                stage.setY(y + MainStage.getHeight() / 2 - 125);
                stage.show();
            }
        });
    }
}
